package com.vst.demo.dao.impl;

import java.util.List;

import javax.annotation.Resource;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import com.vst.demo.dao.ILoginDao;
import com.vst.demo.domain.User;

@Repository("loginDao")
public class LoginDao implements ILoginDao {

	@Resource
	private SessionFactory sessionFactory;

	public List<User> getAllUser() {
		String hsql = " from User ";
		Session session = null;
		if (null == sessionFactory) {
			System.out.println("****************************");
			session = sessionFactory.openSession();
		} else {
			session = sessionFactory.getCurrentSession();
		}
		Query query = session.createQuery(hsql);

		return query.list();
	}
}
